package com.yilin.tms.core.entity.message;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yilin.tms.core.commons.base.BaseEntity;
import com.yilin.tms.core.commons.annotation.Explain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * 推送记录
 * 注意：推送只是一个第三方接口调用及处理记录，不要和内部业务混淆
 *
 * @author zhangjinyuan
 * @date 2022/10/26
 */
@Entity
@Table(name = "message_push_record")
@TableName(value = "message_push_record")
public class PushRecord extends BaseEntity {

    /**
     * 推送目标
     */
    public enum PushTarget {
        pushId(0, "指定PushID"),
        alias(1, "别名用户(别名就是userId)"),
        tags(2, "标签用户(标签就是userType)"),
        all(3, "所有用户"),
        ios(4, "苹果用户"),
        android(5, "安卓用户");

        @EnumValue
        public Integer index;
        public String name;

        PushTarget(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 发送状态
     */
    public enum PushState {
        save(0, "已保存本地 待发送"),
        success(1, "已发送成功"),
        fail(2, "发送失败"),
        receive(3, "已接收");

        @EnumValue
        public Integer index;
        public String name;

        PushState(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 基础信息
     */
    @Explain("推送目标")
    @Column(name = "push_target")
    private PushTarget pushTarget;
    @Explain("发送状态")
    @Column(name = "push_state")
    private PushState pushState;
    //推送参数(pushId/tags/alias)
    @Explain("推送参数")
    @Column(name = "push_param")
    private String pushParam;
    @Explain("通知标题")
    @Column(name = "title")
    private String title;
    @Explain("通知内容")
    @Column(name = "text")
    private String text;
    @Explain("通知发送时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "send_time")
    private Date sendTime;
    @Explain("额外数据")
    @Column(name = "extend_data")
    private String extendData;
    @Explain("推送返回消息")
    @Column(name = "push_msg")
    private String pushMsg;
    //发送失败时重发次数 大于5次不在重发
    @Explain("发送失败时重发次数")
    @Column(name = "send_number")
    private Integer sendNumber;

    public PushTarget getPushTarget() {
        return pushTarget;
    }

    public void setPushTarget(PushTarget pushTarget) {
        this.pushTarget = pushTarget;
    }

    public PushState getPushState() {
        return pushState;
    }

    public void setPushState(PushState pushState) {
        this.pushState = pushState;
    }

    public String getPushParam() {
        return pushParam;
    }

    public void setPushParam(String pushParam) {
        this.pushParam = pushParam;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Date getSendTime() {
        return sendTime;
    }

    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }

    public String getExtendData() {
        return extendData;
    }

    public void setExtendData(String extendData) {
        this.extendData = extendData;
    }

    public Integer getSendNumber() {
        return sendNumber;
    }

    public void setSendNumber(Integer sendNumber) {
        this.sendNumber = sendNumber;
    }

    public String getPushMsg() {
        return pushMsg;
    }

    public void setPushMsg(String pushMsg) {
        this.pushMsg = pushMsg;
    }
}
